﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace 旅游管理员终端
{
    public partial class AdminLogin : Form
    {
        public string connectStr;
        public AdminLogin()
        {
            InitializeComponent();
        }


        private void loginButton_Click(object sender, EventArgs e)
            //登录组件
        {
            connectStr = "server=bj-cynosdbmysql-grp-jzqoeba0.sql.tencentcdb.com;port=24545;user=" + userName.Text + ";password=" + userPassword.Text + ";database=YH_test;charset=utf8";
            //由于C#字符串默认不是UTF-8编码，所以要在连接字符串后加入转码条件
            try
            {
                MySqlConnection conn = new MySqlConnection(connectStr);
                conn.Open();
                Navigator nav = new Navigator(connectStr);
                nav.ShowDialog();
                this.Close();
            }
            catch(Exception ex)
            {
                Hint h = new Hint(ex);
                h.ShowDialog();
                this.Show();
            }
        }

        private void clearButton_Click(object sender, EventArgs e)
            //清空组件
        {
            userName.Text = null;
            userPassword.Text = null;
        }

        private void Exit_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }
    }
}
